package org.example.Demo;


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

//简单参数
@RestController
public class demo2 {

/*    @RequestMapping("/simple")
    public String simple(HttpServletRequest request){
        String name = request.getParameter("name");
        String age = request.getParameter("age");
        System.out.println(name + " :" + age);
        return name + " :" + age;
    }*/

    @RequestMapping("/simple")
    public String simple(@RequestParam(name="name",required = false) String userName, Integer age){
        System.out.println(userName + " :" + age);
        return userName + " :" + age;
    }
}
